Von: Brian Harvey <bh@abbenay.cs.berkeley.edu>
Betreff: Re: [LogoForum] Making money with List Processing...
Datum: Dienstag, 29. Mai 2001 18:14

Bob Gorman <Use-Author-Address-Header@[127.1]> writes:
>>  I believe the LIST is
>>significantly different from the other more common data structures in
>>programming. [...]
>> Logo is a bit more
>>flexible, in that a Variable can contain, Words, Lists (including Property
>>lists) and Arrays. [...]
>>  When I was stuck with
>>BASIC, I had to say: FOR I = 1 to N, do something, NEXT I. Unfortunately,
>>I rarely knew what N would be. I desperately wanted Logo's FOREACH
>>operator.

Actually Logo isn't the champion at this sort of flexibility.  In Logo we
have two aggregate types: lists (which are accessed from the front, with
FIRST, BUTFIRST, etc.) and arrays (which are accessed by indexing, as in
ITEM 5 :X).  Lists are variable-length; arrays are fixed-length.  These
differences in detail reflect to the user the way the two types are
implemented -- arrays with a contiguous block of memory, lists with a bunch
of small blocks, one per element, linked together with pointers.

Advances in programming languages largely mean making implementation
restrictions invisible to the user.  So, in APL and its intellectual
descendents (among which I include Python and ISETL as well as its more direct
descendent J), you have things called arrays, that can be indexed, but can
also grow and shrink dynamically.  The language does the most efficient thing
it can, given the way you use that particular array.

There's nothing about arrays that preclude weak typing (heterogeneous data)
or higher order procedures (FOREACH); other languages lack those features for
different reasons (such as fear of functions-as-data).

P.S.  APL came before Logo!  So our team should have done better.  :-)

P.P.S.  I think, though, that this inarticulate list-loving that you're
talking about probably comes mainly from the ease of creating hierarchical
data structures -- lists of lists -- just by typing in the data:

make "beat [[[John Lennon] [rhythm guitar]] [[Paul McCartney] [bass guitar]]
            [[George Harrison] [lead guitar]] [[Ringo Starr] [drums]]]

And then write programs to query this informal database:

to look :word
foreach filter [submemberp :word ?] :beat "print
end

to submemberp :this :those
if not listp :those [output "false]
output or (memberp :this :those) (apply "or map [submemberp :this ?] :those)
end

? look "Paul
[Paul McCartney] [bass guitar]
? look "guitar
[John Lennon] [rhythm guitar]
[Paul McCartney] [bass guitar]
[George Harrison] [lead guitar]